package org.web.standardplatform.client.domain.buildcode;

import lombok.Getter;
import lombok.Setter;

@Setter
@Getter
public class CodePackageDTO {

    private String tableName;

    private String basePackage;

    private String domainPackage;

    private String daoPackage;

    private String servicePackage;

    private String bizPackage;

    private String dtoPackage;

    private String queryPackage;

    private String sdkPackage;

    private String queryDTOPackage;

    public void initPackage() {
        if (basePackage == null) {
            throw new IllegalArgumentException("basePackage is null");
        }

        if (domainPackage == null) {
            domainPackage = basePackage + ".domain";
        }
        if (queryPackage == null) {
            queryPackage = basePackage + ".domain.query";
        }
        if (daoPackage == null) {
            daoPackage = basePackage + ".dao";
        }
        if (servicePackage == null) {
            servicePackage = basePackage + ".service";
        }
        if (sdkPackage == null) {
            if(basePackage.endsWith(".server")){
                sdkPackage = basePackage.substring(0, basePackage.lastIndexOf(".server")) + ".sdk";
            } else {
                sdkPackage = basePackage + ".sdk";
            }
        }

        if (bizPackage == null) {
            bizPackage = sdkPackage + ".biz";
        }
        if (dtoPackage == null) {
            dtoPackage = sdkPackage + ".dto";
        }
        if (queryDTOPackage == null) {
            queryDTOPackage = sdkPackage + ".dto.query";
        }

    }
}
